package study;

import java.util.Scanner;

import org.apache.commons.math3.util.ArithmeticUtils;


public class gcd {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int first = input.nextInt();
		int second = input.nextInt();
		int a = ArithmeticUtils.gcd(first, second);
		System.out.println(a);
	}

}
